home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume11 / starchart / part29 < prev    next >
Encoding:
Text File  |  1990-03-25  |  42.8 KB  |  1,494 lines

  1. Newsgroups: comp.sources.misc
  2. subject: v11i057: starchart 3.2 Part 29/32
  3. from: ccount@ATHENA.MIT.EDU
  4. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  5.  
  6. Posting-number: Volume 11, Issue 57
  7. Submitted-by: ccount@ATHENA.MIT.EDU
  8. Archive-name: starchart/part29
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then unpack
  12. # it by saving it into a file and typing "sh file".  To overwrite existing
  13. # files, type "sh file -c".  You can also feed this as standard input via
  14. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  15. # will see the following message at the end:
  16. #        "End of archive 29 (of 32)."
  17. # Contents:  starchart/starX11.c
  18. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  19. if test -f 'starchart/starX11.c' -a "${1}" != "-c" ; then 
  20.   echo shar: Will not clobber existing file \"'starchart/starX11.c'\"
  21. else
  22. echo shar: Extracting \"'starchart/starX11.c'\" \(40722 characters\)
  23. sed "s/^X//" >'starchart/starX11.c' <<'END_OF_FILE'
  24. X/*
  25. X * X11 driver for starchart.c 3.0 mainline 4/17/88
  26. X *
  27. X * Driver creates X11 window and draws starchart information inside.
  28. X * Intially window size is variable, but it stays constant once it's
  29. X * mapped.  It handles expose events, even while it's drawing.
  30. X * Includes glyphs for variable stars.
  31. X *
  32. X *
  33. X * Portions Copyright (c) 1989 by Joe Wang (joe@athena.mit.edu)
  34. X *
  35. X * Copyright (c) 1990 by Craig Counterman. All rights reserved.
  36. X *
  37. X * This software may be redistributed freely, not sold.
  38. X * This copyright notice and disclaimer of warranty must remain
  39. X *    unchanged. 
  40. X *
  41. X * No representation is made about the suitability of this
  42. X * software for any purpose.  It is provided "as is" without express or
  43. X * implied warranty, to the extent permitted by applicable law.
  44. X *
  45. X */
  46. X
  47. Xstatic char rcsid[]="$Header: starX11.c,v 2.16 90/02/19 17:53:06 ccount Exp $";
  48. X
  49. X#include <stdio.h>
  50. X#include <math.h>
  51. X#include <ctype.h>
  52. X#include "star3.h"
  53. X
  54. X#ifndef SYSV
  55. X#include <strings.h>
  56. X#else
  57. X#include <string.h>
  58. X#endif
  59. X
  60. X#include <X11/cursorfont.h>
  61. X#include <X11/Intrinsic.h>
  62. X#include <X11/Xlib.h>
  63. X#include <X11/Xutil.h>
  64. X
  65. Xchar *malloc();
  66. X
  67. X/* X items */
  68. XDisplay *display;            /* connection to display server */
  69. Xint screen_num;
  70. XScreen screen;
  71. XWindow root, window;         /* window to graphics in */
  72. XDrawable draw_into;
  73. XColormap default_cmap;       /* colormap */
  74. XGC default_GC;               /* graphics context */
  75. XXFontStruct *default_font;   /* default font */
  76. XXFontStruct *greek_font;     /* Greek font */
  77. XPixmap backup;               /* backup for expose events */
  78. XPixel black, white, foreground, background;
  79. XPixel *pixels;             /* color map cells */
  80. XPixel *star_pixels;         /* color map cells for super color stars */
  81. Xint ncolors, star_colors;
  82. XXEvent event;             /* event structure */
  83. XXGCValues values_GC;         /* modify GC */
  84. Xunsigned int width, height;
  85. X
  86. XBoolean reverse;
  87. X
  88. XBool use_backup = FALSE;
  89. XBool hide_drawing = FALSE;
  90. XBool post_preview = FALSE;
  91. XBool post_landscape = FALSE;
  92. X#ifdef USE_X_DASHES
  93. XBool use_x_dashes = TRUE;
  94. X#else
  95. XBool use_x_dashes = FALSE;
  96. X#endif
  97. XBool is_color = TRUE;        /* Is it color? */
  98. XBool is_super_color = TRUE;    /* Is it many color? */
  99. X
  100. X
  101. Xint Xargc = 1;
  102. Xchar *Xargv[40];
  103. X
  104. X
  105. X
  106. X#ifdef STARX11
  107. Xchar prog[] = "StarX11";
  108. X#else
  109. Xextern char prog[];
  110. X#endif
  111. X
  112. X#include "icon.h"
  113. X
  114. X#define BLACK 0
  115. X#define WHITE 1
  116. X#define RED 2
  117. X#define ORANGE 3
  118. X#define YELLOW 4
  119. X#define GREEN 5
  120. X#define CYAN 6
  121. X#define BLUE 7
  122. X#define VIOLET 8
  123. X#define BLUE_WHITE 9
  124. X
  125. X/* Externs */
  126. Xextern int g_argc;
  127. Xextern char **g_argv;
  128. X
  129. Xextern char *title;
  130. X
  131. Xextern mapwindow *mapwin[MAXWINDOWS];
  132. Xextern int numwins;
  133. X
  134. Xextern int cur_function;
  135. Xextern int cur_map_type;
  136. Xextern int cur_map_tag;
  137. Xextern char *cur_tag_field;
  138. X
  139. X
  140. X/* Scale multiplier, minimum,
  141. X   mangitude change, maximum, for thumbnail */
  142. X#define THSMUL 1.2
  143. X#define THSMIN 12.0
  144. X#define THMADJ 2.5
  145. X#define THMMAX 8.0
  146. X
  147. Xmapwindow fullpage = {920, 700, 20, 48,
  148. X                      8.0, 3.0, 2.05, FULLPAGEMAP, 0, "String",
  149. X                      SANSONS, FALSE, FALSE, 7.5, 5.0, 0.0, 0.0, FALSE,};
  150. Xmapwindow mainmap = {920, 480, 20, 268,
  151. X                     8.0, 3.0, 2.05, MAINMAP, 0, "String", 
  152. X                     SANSONS, FALSE, FALSE, 7.5, 5.0, 0.0, 0.0, FALSE,};
  153. Xmapwindow thumbmap = {480, 195, 420, 35, 6.2+THMADJ, 1.0+THMADJ, 2.05+THMADJ,
  154. X                     THUMBNAIL, 0, "String", SANSONS, FALSE, FALSE, 7.5, 5.0,
  155. X                     0.0, 0.0, FALSE,};
  156. X
  157. Xint htick_lim = 2;
  158. Xint htext_lim = 37;
  159. Xint htext_xoff = 2;
  160. Xint htext_yoff = 12;
  161. Xint vtick_lim = 2;
  162. Xint vtext_lim = 12;
  163. Xint vtext_xoff = 16;
  164. Xint vtext_yoff = 0;
  165. X
  166. X/* externs for labels */
  167. Xint x_nameoffset = 10, y_nameoffset = 0;
  168. Xint x_lbloffset = 7, y_lbloffset = 0;
  169. Xint x_magoffset = 7, y_magoffset = -10;
  170. X
  171. X/* externs for legend: variables of positioning are here */
  172. Xint l_til=105;
  173. Xint l_stil=85;
  174. X
  175. Xint l_lmar1=25;
  176. Xint l_lmar2=50;
  177. Xint l_ltext=75;
  178. Xint l_rmar1=150;
  179. Xint l_rmar2=175;
  180. Xint l_rtext=200;
  181. X
  182. Xint l_line1=72;
  183. Xint l_line2=60;
  184. Xint l_line3=47;
  185. Xint l_line4=35;
  186. Xint l_line5=22;
  187. Xint l_line6=10;
  188. X
  189. X/* Point sizes for font calls */
  190. Xint titlesize=18;
  191. Xint subtlsize=12;
  192. Xint namesize=10;
  193. Xint lblsize=10;
  194. Xint magsize=8;
  195. X
  196. X/* Fonts for font calls */
  197. Xint namefnt=TIMESROMAN;
  198. Xint lblfnt=TIMESROMAN;
  199. Xint magfnt=COURIER;
  200. Xint titlefnt=TIMESBOLD;
  201. Xint subtlfnt=TIMESROMAN;
  202. X
  203. X/* Scale multiplier, minimum,
  204. X   mangitude change, maximum, for thumbnail,*/
  205. Xdouble th_smul=THSMUL;
  206. Xdouble th_smin=THSMIN;
  207. Xdouble th_madj=THMADJ;
  208. Xdouble th_mmax=THMMAX;
  209. X
  210. X#define MAX(a,b) ((a)>(b)?(a):(b))
  211. X#define MIN(a,b) ((a)<(b)?(a):(b))
  212. X
  213. X/* Font names */
  214. X#ifdef RELEASE3_FONTS
  215. Xstatic char *default_font_name = "*helvetica-medium-r-normal--10*";
  216. Xstatic char *greek_font_name = "*symbol-medium-r-normal--10*";
  217. Xstatic char *timesroman_font_name = "*times-medium-r-normal--";
  218. Xstatic char *timesbold_font_name = "*times-bold-r-normal--";
  219. Xstatic char *timesital_font_name = "*times-roman-i-normal--";
  220. Xstatic char *timesboldital_font_name = "*times-bold-i-normal--";
  221. Xstatic char *helv_font_name = "*helvetica-medium-r-normal--";
  222. Xstatic char *helvbold_font_name = "*helvetica-bold-r-normal--";
  223. Xstatic char *helvital_font_name = "*helvetica-medium-o-normal--";
  224. Xstatic char *helvboldital_font_name = "*helvetica-bold-o-normal--";
  225. Xstatic char *courier_font_name = "*courier-medium-r-normal--";
  226. Xstatic char *courital_font_name = "*courier-medium-i-normal--";
  227. Xstatic char *courbold_font_name = "*courier-bold-r-normal--";
  228. Xstatic char *couritalbold_font_name = "*courier-bold-o-normal--";
  229. X#else
  230. Xstatic char *default_font_name = "helvetica-medium10";
  231. Xstatic char *greek_font_name = "symbol-medium10";
  232. Xstatic char *timesroman_font_name = "times-roman";
  233. Xstatic char *timesbold_font_name = "times-bold";
  234. Xstatic char *timesital_font_name = "times-italic";
  235. Xstatic char *timesboldital_font_name = "times-bold-italic";
  236. Xstatic char *helv_font_name = "helvetica-medium";
  237. Xstatic char *helvbold_font_name = "helvetica-bold";
  238. Xstatic char *helvital_font_name = "helvetica-oblique";
  239. Xstatic char *helvboldital_font_name = "helvetica-boldoblique";
  240. Xstatic char *courier_font_name = "courier-medium";
  241. Xstatic char *courital_font_name = "courier-medium";
  242. Xstatic char *courbold_font_name = "courier-bold";
  243. Xstatic char *couritalbold_font_name = "courier-bold";
  244. X#endif /* RELEASE3_FONTS */
  245. X
  246. X
  247. X
  248. X/* Device control argument */
  249. XD_control_arg(s)
  250. Xchar *s;
  251. X{
  252. X  int i = 0;
  253. X  int c;
  254. X  int j;
  255. X
  256. X  while (c = s[i++])
  257. X    switch (c) {
  258. X    case 'p': /* Postscript preview */
  259. X      post_preview = TRUE;
  260. X      break;
  261. X    case 'l': /* Postscript landscape */
  262. X      post_preview = TRUE;
  263. X      post_landscape = TRUE;
  264. X      break;
  265. X    case 'h': /* Hide */
  266. X      hide_drawing = use_backup = TRUE;
  267. X      break;
  268. X    case 'b': /* Use backup */
  269. X      use_backup = TRUE;
  270. X      break;
  271. X    case 'm': /* monochrome display */
  272. X      is_color = FALSE;
  273. X      break;
  274. X#ifdef STARXAW
  275. X    case 't': /* Toolkit */
  276. X      /* skip current argument */
  277. X      j = i-1;
  278. X      while (s[j]) {
  279. X    if (s[j] == ' ') {
  280. X      s[j] = '\0';
  281. X      if (Xargc < 39)
  282. X        Xargv[Xargc++] = &s[j+1];
  283. X    };
  284. X    j++;
  285. X      };
  286. X      i = j-1;
  287. X      break;
  288. X#endif
  289. X    default:
  290. X      break;
  291. X    }
  292. X}
  293. X
  294. X
  295. X#ifdef STARX11
  296. X/* Open the device */
  297. XD_open()
  298. X{
  299. X  int x, y;
  300. X  unsigned int border, depth, map_width;
  301. X  Pixmap icon;
  302. X  XSizeHints sizehints;
  303. X  double legend_spacing;
  304. X
  305. X  if (!(display = XOpenDisplay(NULL)))
  306. X    return FALSE;
  307. X   
  308. X  X_setdisplay();
  309. X
  310. X  /* open window */
  311. X  window = XCreateSimpleWindow(display, RootWindow(display,screen_num), 12, 12,
  312. X                                 720, 540, 1, foreground, background);
  313. X
  314. X  if (post_preview) {
  315. X    sizehints.flags = PSize|PMinSize|PMaxSize;
  316. X    if (post_landscape) {
  317. X      sizehints.width = sizehints.min_width = sizehints.max_width = 792;
  318. X      sizehints.height = sizehints.min_height = sizehints.max_height = 576;
  319. X    } else {
  320. X      sizehints.width = sizehints.min_width = sizehints.max_width = 576;
  321. X      sizehints.height = sizehints.min_height = sizehints.max_height = 792;
  322. X    };
  323. X  } else {
  324. X    sizehints.flags = PMinSize;
  325. X    sizehints.min_width = 550; sizehints.min_height = 550;
  326. X  }
  327. X
  328. X  icon = XCreateBitmapFromData(display, window, icon_bits, 
  329. X                               icon_width, icon_height);
  330. X  Xargv[0] = g_argv[0];
  331. X  XSetStandardProperties(display, window, prog, prog, icon, Xargv, Xargc,
  332. X                         &sizehints);
  333. X  XDefineCursor(display, window, XCreateFontCursor(display, XC_crosshair));
  334. X  XSelectInput(display, window, StructureNotifyMask);
  335. X  XMapWindow(display, window);
  336. X  while(!XCheckTypedWindowEvent(display, window, MapNotify, &event));
  337. X  XSelectInput(display, window, ExposureMask);
  338. X
  339. X  XGetGeometry(display, window, &root, &x, &y, &width, 
  340. X               &height, &border, &depth);
  341. X  sizehints.max_width = sizehints.min_width = width;
  342. X  sizehints.max_height = sizehints.min_height = height;
  343. X
  344. X
  345. X  map_width = width - 72;
  346. X
  347. X  fullpage.width = map_width;
  348. X  fullpage.height = height - 72;
  349. X  fullpage.x_offset = 18;
  350. X  fullpage.y_offset = 36;
  351. X
  352. X  /* main is 7/10 the printing space 
  353. X   */
  354. X  mainmap.width = map_width;
  355. X  mainmap.height = ((height - 72)*7)/10;
  356. X  mainmap.x_offset = 18;
  357. X  mainmap.y_offset = 18 + ((height - 72)*2.5)/10;
  358. X
  359. X  /* Thumbscale is 2/10 the printing space */
  360. X  thumbmap.width = map_width/2;
  361. X  thumbmap.height = ((height - 72)*2)/10;
  362. X  thumbmap.x_offset = 18 + map_width/2;
  363. X  thumbmap.y_offset = 18;
  364. X
  365. X  /* Need to adjust label here */
  366. X  /* Want top of l_til to be at top of thumbmap */
  367. X  l_til = thumbmap.height + thumbmap.y_offset - titlesize;
  368. X  /* Space text in legends to fill space.  Leave 10 on bottom.
  369. X     Text totals 6*namesize+subtlsize. */
  370. X
  371. X  legend_spacing = (l_til - 10 - 6*namesize - subtlsize)/7;
  372. X  if (legend_spacing < 2) legend_spacing = 2;
  373. X
  374. X  l_stil = l_til - subtlsize - legend_spacing;
  375. X  l_line1 = l_stil - namesize - legend_spacing;
  376. X  l_line2 = l_line1 - namesize - legend_spacing;
  377. X  l_line3 = l_line2 - namesize - legend_spacing;
  378. X  l_line4 = l_line3 - namesize - legend_spacing;
  379. X  l_line5 = l_line4 - namesize - legend_spacing;
  380. X  l_line6 = l_line5 - namesize - legend_spacing;
  381. X
  382. X
  383. X  /* Actually, we left too much space above,
  384. X     for proper postscript simulation.
  385. X     We can make the maps higher */
  386. X  if (!post_preview) {
  387. X    fullpage.height = height - fullpage.y_offset - 18;
  388. X    mainmap.height = height - mainmap.y_offset - 18;
  389. X  }
  390. X
  391. X
  392. X  sizehints.flags = PSize|PMinSize|PMaxSize;
  393. X  XSetNormalHints(display, window, &sizehints);
  394. X
  395. X  if ((!is_color) && use_backup)
  396. X    backup = XCreatePixmap(display, window, width, height, depth);
  397. X  else { /* Can't use backup pixmap on color: not enough memory */
  398. X    use_backup = FALSE;
  399. X    hide_drawing = FALSE;
  400. X  }
  401. X  draw_into = backup ? backup : window;
  402. X/* Should perhaps try and check for failure, and use some other
  403. X   way of selecting use of window vs. backup */
  404. X
  405. X    
  406. X  values_GC.foreground = background; values_GC.background = foreground;
  407. X  XChangeGC(display, default_GC, GCForeground|GCBackground, &values_GC);
  408. X  XFillRectangle(display, draw_into, default_GC, 0, 0, width, height);
  409. X  XSetForeground(display, default_GC, foreground);
  410. X  XSetBackground(display, default_GC, background);
  411. X
  412. X  return TRUE;                /* open successful */
  413. X}
  414. X
  415. X/* Close the device */
  416. XD_close()
  417. X{
  418. X  Window closebox;         /* window to do close in */
  419. X  XEvent closebox_event, window_event;
  420. X  int i;
  421. X  double lat, lon, tlat, tlon;
  422. X  char outstr[81];
  423. X  int ra_h, ra_m, ra_s;
  424. X  int de_d, de_m, de_s;
  425. X  char dsign;
  426. X
  427. X
  428. X  flushlines();
  429. X  if (use_backup)
  430. X    XCopyArea(display, backup, window, default_GC, 0, 0, width, height,
  431. X          0, 0);
  432. X
  433. X  closebox =XCreateSimpleWindow(display,window, 0, 0, 10, 10, 1, background,
  434. X                foreground);
  435. X  XDefineCursor(display, closebox, 
  436. X                XCreateFontCursor(display, XC_top_left_arrow));
  437. X  XMapWindow(display,closebox);
  438. X  XSelectInput(display, closebox, ButtonPressMask);
  439. X  XSelectInput(display, window, ButtonPressMask|ExposureMask);
  440. X
  441. X  D_comment("Waiting for close of window or mouse button 1 or 3 input");
  442. X
  443. X  while (!XCheckWindowEvent(display, closebox, ButtonPressMask,
  444. X                 &closebox_event))
  445. X    {
  446. X      if (XCheckWindowEvent(display, window, ExposureMask, &window_event)
  447. X      && (window_event.type == Expose))
  448. X    if (use_backup)
  449. X      XCopyArea(display, backup, window, default_GC,
  450. X            window_event.xexpose.x, window_event.xexpose.y,
  451. X            window_event.xexpose.width, window_event.xexpose.height,
  452. X            window_event.xexpose.x, window_event.xexpose.y);
  453. X
  454. X      if (XCheckWindowEvent(display, window, ButtonPressMask, &window_event)
  455. X      && (window_event.type == ButtonPress)) {
  456. X    if ((i = invxform((int) window_event.xbutton.x,
  457. X             (int) height - window_event.xbutton.y,
  458. X             &lat, &lon)) >= 0) {
  459. X      if (lon < 0.0) lon += 360.0;
  460. X      tlon = lon / 15.0;
  461. X
  462. X      ra_h = tlon;
  463. X      ra_m = (tlon - ra_h) * 60 + (0.5 / 60);
  464. X      ra_s = (((tlon - ra_h) * 60) - ra_m) * 60 + 0.5;
  465. X
  466. X      if (ra_s >= 60) {ra_s -= 60; ra_m++;};
  467. X      if (ra_m >= 60) {ra_m -= 60; ra_h++;};
  468. X
  469. X
  470. X      if (lat < 0.0) {
  471. X        tlat = -lat;
  472. X        dsign = '-';
  473. X      } else {
  474. X        tlat = lat;
  475. X        dsign = '+';
  476. X      }
  477. X
  478. X      de_d = tlat;
  479. X      de_m = (tlat - de_d) * 60 + (0.5 / 60);
  480. X      de_s = (((tlat - de_d) * 60) - de_m) * 60 + 0.5;
  481. X
  482. X      if (de_s >= 60) {de_s -= 60; de_m++;};
  483. X      if (de_m >= 60) {de_m -= 60; de_d++;};
  484. X
  485. X
  486. X      sprintf(outstr, "RA: %2dh%2dm%2ds   dec: %c%2dd%2dm%2ds",
  487. X          ra_h, ra_m, ra_s, dsign, de_d, de_m, de_s);
  488. X      D_comment(outstr);
  489. X      if (window_event.xbutton.button == Button3)
  490. X        dblookup(i, lat, lon, 10);
  491. X    } else {
  492. X/*      fprintf(stderr, "Returned -1\n");*/
  493. X    }
  494. X      }
  495. X    }
  496. X  
  497. X  XCloseDisplay(display);
  498. X}
  499. X
  500. X#endif /* STARX11 */
  501. X
  502. X#ifndef STARXTK
  503. XX_setdisplay()
  504. X{
  505. X  char *str;
  506. X  char *fore_color, *back_color;
  507. X  XColor cdef;
  508. X  Pixel *planes;
  509. X
  510. X  screen_num = DefaultScreen(display);
  511. X  black = BlackPixel(display, screen_num);
  512. X  white = WhitePixel(display, screen_num);
  513. X
  514. X  if ((str = XGetDefault(display, prog, "ReverseVideo")) 
  515. X     && strcmp(str, "on") == 0)
  516. X     reverse = 1;
  517. X  fore_color = XGetDefault(display, prog, "ForeGround");
  518. X  back_color = XGetDefault(display, prog, "BackGround");
  519. X
  520. X  /* get global defaults from .Xdefaults */
  521. X  get_defaults();
  522. X
  523. X  default_GC = DefaultGC(display, screen_num);
  524. X  default_cmap = DefaultColormap(display, screen_num);
  525. X  default_font = XLoadQueryFont(display, default_font_name);
  526. X
  527. X  greek_font = XLoadQueryFont(display, greek_font_name);
  528. X
  529. X  /* create color map */
  530. X
  531. X  if (reverse) {
  532. X    foreground = black;
  533. X    background = white;
  534. X  }
  535. X  else {
  536. X    foreground = white;
  537. X    background = black;
  538. X  }
  539. X
  540. X  is_color &= (DisplayPlanes(display, screen_num) >= 4);
  541. X  is_super_color = is_color & (DisplayPlanes(display, screen_num) >= 6);
  542. X  ncolors = (is_color ? 12 : 2);
  543. X  star_colors = (is_super_color ? 65: 0);
  544. X
  545. X  if (is_color) {
  546. X    pixels = (Pixel *)
  547. X      malloc((unsigned int) (star_colors+ncolors)*sizeof(Pixel));
  548. X    if (!XAllocColorCells(display, default_cmap, 0, planes,
  549. X              0, pixels, ncolors+star_colors))  {
  550. X      fprintf(stderr, "Error, can't get color cells\n");
  551. X      exit(10);
  552. X    }
  553. X
  554. X    cdef.flags = DoRed|DoBlue|DoGreen;
  555. X    if (!fore_color || 
  556. X        !XParseColor(display, default_cmap, fore_color, &cdef)) {
  557. X      cdef.pixel = foreground ;
  558. X      XQueryColor(display, default_cmap, &cdef) ;
  559. X    }
  560. X    cdef.pixel = pixels[0] ;
  561. X    XStoreColor(display, default_cmap, &cdef) ;
  562. X
  563. X    if (!back_color || 
  564. X        !XParseColor(display, default_cmap, back_color, &cdef)) {
  565. X      cdef.pixel = background ;
  566. X      XQueryColor(display, default_cmap, &cdef) ;
  567. X    }
  568. X    cdef.pixel = pixels[1] ;
  569. X    XStoreColor(display, default_cmap, &cdef) ;
  570. X    D_setcolors();
  571. X  }
  572. X}
  573. X#endif /* not STARXTK */
  574. X
  575. X/* Readstar globals */
  576. Xextern double obj_lat, obj_lon, obj_mag;
  577. Xextern char obj_type[3], obj_color[3], obj_label[3];
  578. Xextern char obj_constell[3], obj_name[];
  579. Xextern char *obj_commnt, fileline[];
  580. X
  581. X/* needed by readstar */
  582. Xint (*readfile)();
  583. Xextern char *cur_file_name;
  584. X
  585. Xdblookup(winnum, lat, lon, dpix)
  586. X     int winnum;
  587. X     double lat, lon;
  588. X     int dpix;
  589. X{
  590. X  int i;
  591. X  double delta;
  592. X  double f_east, f_north, f_west, f_south;
  593. X  FILE *file1, *file2;
  594. X  char ibuf[2020], fname[1030], ftypestr[32];
  595. X  int n;
  596. X  int ftype;
  597. X
  598. X#ifdef STARXAW
  599. X  buffer_comment("Looking for object", FALSE);
  600. X#else
  601. X  D_comment("Looking for object");
  602. X#endif
  603. X
  604. X  delta = mapwin[winnum]->c_scale * dpix;
  605. X
  606. X  for (i = 0; i < mapwin[winnum]->numfiles; i++) {
  607. X    if ((file1 = fopen(mapwin[winnum]->file[i].name, "r")) == NULL) continue;
  608. X
  609. X    cur_file_name = mapwin[winnum]->file[i].name;
  610. X    ftype = mapwin[winnum]->file[i].type;
  611. X    if (mapwin[winnum]->file[i].type == INDEXTYPE) {
  612. X      /* read each line of index file, parse data on the files indexed:
  613. X     region_included file_name
  614. X         use an indexed file if the point is in the region */
  615. X
  616. X      while (!feof(file1)) {
  617. X    fgets(ibuf, 2000, file1);
  618. X    n = sscanf(ibuf, "%lf %lf %lf %lf %1000s %30s\n", &f_east, &f_north,
  619. X           &f_west, &f_south, fname, ftypestr);
  620. X    if ((n != 6) || feof(file1)) continue;
  621. X
  622. X    f_east *= 15.0;
  623. X    f_west *= 15.0;
  624. X
  625. X    if (westof(lon, f_east) && eastof(lon, f_west)
  626. X        && (lat >= f_south) && (lat <= f_north)) {
  627. X      if ((file2 = fopen(fname, "r")) == NULL) {
  628. X        fprintf(stderr, "%s: error, couldn't open '%s' for reading.\n",
  629. X            prog, fname);
  630. X      } else {
  631. X        cur_file_name = fname;
  632. X
  633. X        ftype = tr_fty(ftypestr);
  634. X
  635. X        if (ftype == INDEXTYPE)  {
  636. X          fprintf(stderr,
  637. X  "%s: error, can't use type INDEXTYPE file '%s' from another index file.\n",
  638. X              prog, fname);
  639. X        } else {
  640. X          do_look(file2, ftype, lat, lon, delta);
  641. X        }
  642. X        fclose(file2);
  643. X        cur_file_name = "";
  644. X      }
  645. X    }
  646. X      }
  647. X    } else {
  648. X      do_look(file1, ftype, lat, lon, delta);
  649. X    }
  650. X
  651. X    fclose(file1);
  652. X  };
  653. X
  654. X#ifdef STARXAW
  655. X  buffer_comment("Done search", FALSE);
  656. X#else
  657. X  D_comment("Done search");
  658. X#endif
  659. X}
  660. X
  661. Xdo_look(file, ftype, lat, lon, delta)
  662. XFILE *file;
  663. Xint ftype;
  664. Xdouble lat, lon, delta;
  665. X{
  666. X  double dlat, dlon;
  667. X  double tlat, tlon;
  668. X  int ra_h, ra_m, ra_s;
  669. X  int de_d, de_m, de_s;
  670. X  char dsign;
  671. X
  672. X  char outstr[81];
  673. X
  674. X
  675. X  while (!(*readfile)(file, ftype)) {
  676. X    dlat = fabs(obj_lat - lat);
  677. X    dlon = fabs(obj_lon - lon);
  678. X    if ((dlat <= delta) && (dlon <= delta)) {
  679. X      tlon = obj_lon/15.0;
  680. X      ra_h = tlon;
  681. X      ra_m = (tlon - ra_h) * 60 + (0.5 / 60);
  682. X      ra_s = (((tlon - ra_h) * 60) - ra_m) * 60 + 0.5;
  683. X
  684. X      if (ra_s >= 60) {ra_s -= 60; ra_m++;};
  685. X      if (ra_m >= 60) {ra_m -= 60; ra_h++;};
  686. X
  687. X
  688. X      if (obj_lat < 0.0) {
  689. X    tlat = -obj_lat;
  690. X    dsign = '-';
  691. X      } else {
  692. X    tlat = obj_lat;
  693. X    dsign = '+';
  694. X      }
  695. X
  696. X      de_d = tlat;
  697. X      de_m = (tlat - de_d) * 60 + (0.5 / 60);
  698. X      de_s = (((tlat - de_d) * 60) - de_m) * 60 + 0.5;
  699. X
  700. X      if (de_s >= 60) {de_s -= 60; de_m++;};
  701. X      if (de_m >= 60) {de_m -= 60; de_d++;};
  702. X
  703. X
  704. X
  705. X      sprintf(outstr,
  706. X      "%2dh%2dm%2ds %c%2dd%2dm%2ds %5.2f %2s %2s %2s %3s %-25.25s %-14.14s",
  707. X          ra_h, ra_m, ra_s, dsign, de_d, de_m, de_s, obj_mag,
  708. X          obj_type,  obj_color, obj_label, obj_constell,
  709. X          obj_name, obj_commnt);
  710. X#ifdef STARXAW
  711. X      buffer_comment(outstr, FALSE);
  712. X#else
  713. X      D_comment(outstr);
  714. X#endif
  715. X    }
  716. X  }
  717. X}
  718. X
  719. X
  720. Xstatic int current_x, current_y;
  721. X
  722. X/* Move to (x, y) */
  723. XD_move(x, y)
  724. X     int x, y;
  725. X{
  726. X  current_x = x; current_y = y;
  727. X}
  728. X
  729. X
  730. Xstatic int curr_lsty = -1;
  731. X/* Draw a line of style line_style from the current point to (x, y) */
  732. XD_draw(x, y, line_style)
  733. X     int x, y, line_style;
  734. X{
  735. X  int xline_sty;
  736. X  int dashes = 1;
  737. X
  738. X#ifdef STARXAW
  739. X  if (is_killed()) return; /* Return if process_events returns TRUE,
  740. X                    i.e. if the close box has been hit */
  741. X#endif
  742. X
  743. X  switch (cur_function) {
  744. X  case CHRTOUTLN:
  745. X  case CHRTHTICK:
  746. X  case CHRTVTICK:
  747. X    xline_sty = LineSolid;
  748. X    dashes = 1;
  749. X    break;
  750. X  case GRID_RA:
  751. X  case GRID_DEC:
  752. X    xline_sty = LineDoubleDash;
  753. X    dashes = 4;
  754. X    break;
  755. X  case ECLIPT:
  756. X    xline_sty = LineDoubleDash;
  757. X    dashes = 1;
  758. X    break;
  759. X  case CONSTBOUND:
  760. X    xline_sty = LineDoubleDash;
  761. X    dashes = 6;
  762. X    break;
  763. X  case CONSTPATTRN:
  764. X    xline_sty = LineDoubleDash;
  765. X    dashes = 8;
  766. X    break;
  767. X  case CONSTNAME:
  768. X  case CHARTFILE:
  769. X  default:
  770. X    switch (line_style) {
  771. X    case SOLID:
  772. X    case VECSOLID:
  773. X      xline_sty = LineSolid;
  774. X      dashes = 1;
  775. X      break;
  776. X    case DASHED:
  777. X    case VECDASH:
  778. X      xline_sty = LineDoubleDash;
  779. X      dashes = 5;
  780. X      break;
  781. X    case DOTTED:
  782. X    case VECDOT:
  783. X      xline_sty = LineDoubleDash;
  784. X      dashes = 1;
  785. X      break;
  786. X    default:
  787. X      xline_sty = LineSolid;
  788. X      dashes = 1;
  789. X      break;
  790. X    };
  791. X    break;
  792. X  }
  793. X
  794. X/* Some servers can't do dashes */
  795. X  if (!use_x_dashes)
  796. X    xline_sty = LineSolid;
  797. X
  798. X
  799. X  if (xline_sty != curr_lsty) {
  800. X    values_GC.line_style = xline_sty;
  801. X    values_GC.dashes = dashes;
  802. X    XChangeGC(display, default_GC, GCLineStyle | GCDashList, &values_GC);
  803. X  }
  804. X
  805. X  XDrawLine(display, draw_into, default_GC,
  806. X        current_x, height - current_y, x, height - y);
  807. X
  808. X
  809. X  curr_lsty = xline_sty;
  810. X
  811. X  if ((use_backup) && !hide_drawing)
  812. X    XCopyArea(display, backup, window, default_GC, 0, 0, width, height,
  813. X          0, 0);
  814. X
  815. X/*  XFlush(display);*/
  816. X
  817. X  current_x = x; current_y = y;
  818. X}
  819. X/* This routine is encouraged to look at the extern cur_funtion
  820. X   and change the line style drawn as desired */
  821. X
  822. X
  823. X/* Move to (x1, y1) then draw a line of style line_style to (x2, y2) */
  824. XD_movedraw(x1, y1, x2, y2, line_style)
  825. X     int x1, y1, x2, y2, line_style;
  826. X{
  827. X  D_move(x1, y1);
  828. X  D_draw(x2, y2, line_style);
  829. X}
  830. X
  831. X
  832. Xstatic XPoint areapts[1000];
  833. Xstatic int nareapts;
  834. X/* Move to (x, y) to begin an area */
  835. XD_areamove(x, y)
  836. X     int x, y;
  837. X{
  838. X  nareapts = 0;
  839. X  areapts[nareapts].x = x;
  840. X  areapts[nareapts].y = height - y;
  841. X  nareapts++;
  842. X}
  843. X
  844. X/* Add a segment to the area border */
  845. XD_areaadd(x, y)
  846. X     int x, y;
  847. X{
  848. X  areapts[nareapts].x = x;
  849. X  areapts[nareapts].y = height - y;
  850. X  nareapts++;
  851. X}
  852. X
  853. X/* Fill the area, after adding the last segment */
  854. XD_areafill(x, y)
  855. X     int x, y;
  856. X{
  857. X  areapts[nareapts].x = x;
  858. X  areapts[nareapts].y = height - y;
  859. X  nareapts++;
  860. X
  861. X#ifdef STARXAW
  862. X  if (is_killed()) return; /* Return if process_events returns TRUE,
  863. X                    i.e. if the close box has been hit */
  864. X#endif
  865. X
  866. X  XFillPolygon(display, draw_into, default_GC,
  867. X           areapts, nareapts, Complex, CoordModeOrigin);
  868. X  nareapts = 0;
  869. X}
  870. X
  871. X
  872. X
  873. X
  874. Xstatic int curr_colr;
  875. X/* Set the color to be used for lines, areas and text */
  876. X/* color_str is a 2 char (+ '\0') string
  877. X   containing a specification for a color,
  878. X   e.g. "G2" for the color of a star of spectral class G2, or "r7" for
  879. X   red, level seven.  The interpretation of the color string is left to
  880. X   the device driver */
  881. XD_color(color_str)
  882. X     char *color_str;
  883. X{
  884. X  Pixel colr;
  885. X  int class, subclass;
  886. X  static char *table = "OBAFGKMRNSrgbycpow";
  887. X  static int spectra[10] = {
  888. X    BLUE_WHITE, BLUE, WHITE, WHITE, YELLOW, ORANGE, RED, RED, RED};
  889. X
  890. X  static int super_spectra[][10] = {
  891. X    /*         0   1   2   3   4   5   6   7   8   9   */
  892. X    /* O */ { 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 },
  893. X    /* B */ {  0,  1,  2,  3,  3,  4,  4,  4,  5,  6 },
  894. X    /* A */ {  7,  7,  8,  9,  9, 10, 10, 10, 10, 10 },
  895. X    /* F */ { 11, 11, 12, 12, 12, 13, 13, 13, 14, 14 },
  896. X    /* G */ { 15, 15, 15, 15, 15, 16, 16, 16, 16, 16 },
  897. X    /* K */ { 17, 17, 18, 18, 18, 19, 19, 19, 19, 19 },
  898. X    /* M */ { 20, 20, 21, 22, 23, 24, 25, 26, 26, 26 },
  899. X    /* R */ { 27, 27, 27, 28, 28, 28, 28, 28, 29, 30 },
  900. X    /* N */ { 27, 27, 27, 28, 28, 28, 28, 28, 29, 30 },
  901. X    /* S */ { 30, 30, 30, 30, 31, 31, 31, 31, 31, 31 },
  902. X    /* r */ { 33, 33, 33, 34, 34, 34, 35, 35, 35, 36 },
  903. X    /* g */ { 37, 37, 37, 38, 38, 38, 39, 39, 39, 40 },
  904. X    /* b */ { 41, 41, 41, 42, 42, 42, 43, 43, 43, 44 },
  905. X    /* y */ { 45, 45, 45, 46, 46, 46, 47, 47, 47, 48 },
  906. X    /* c */ { 49, 49, 49, 50, 50, 50, 51, 51, 51, 52 },
  907. X    /* p */ { 53, 53, 53, 54, 54, 54, 55, 55, 55, 56 },
  908. X    /* o */ { 57, 57, 57, 58, 58, 58, 59, 59, 59, 60 },
  909. X    /* w */ { 61, 61, 61, 62, 62, 62, 63, 63, 63, 64 }
  910. X      };
  911. X
  912. X  if (!is_color) return;
  913. X#ifdef STARXAW
  914. X  if (is_killed()) return; /* Return if process_events returns TRUE,
  915. X                    i.e. if the close box has been hit */
  916. X#endif
  917. X
  918. X
  919. X  class = 0;
  920. X  while (table[class] && (table[class] != color_str[0])) class++;
  921. X
  922. X  if (is_super_color) {
  923. X    subclass = isdigit(color_str[1]) ? color_str[1] - '0' : 0;
  924. X    colr = table[class] ? star_pixels[super_spectra[class][subclass]] : 
  925. X      pixels[WHITE];
  926. X  } else
  927. X    colr = table[class] ? pixels[spectra[class]] : pixels[WHITE];
  928. X
  929. X  if (colr != curr_colr) {
  930. X    flushlines();
  931. X    XSetForeground(display, default_GC, colr);
  932. X  };
  933. X}
  934. X
  935. X
  936. Xstatic int current_font = -1, current_fsize = -1;
  937. Xstatic XFontStruct *curr_xfont;
  938. X
  939. X/* Set the font and font size to be used for text. */
  940. X/* Note order of args */
  941. XD_fontsize(fsize, font)
  942. X     int font, fsize;
  943. X{
  944. X  char *fontname, readname[50];
  945. X
  946. X#ifdef STARXAW
  947. X  if (is_killed()) return; /* Return if process_events returns TRUE,
  948. X                    i.e. if the close box has been hit */
  949. X#endif
  950. X
  951. X  switch(cur_function) {
  952. X  case CHRTOUTLN:
  953. X    break;
  954. X  case CHRTHTICK:
  955. X  case CHRTVTICK:
  956. X    font = TIMESBOLD;
  957. X    break;
  958. X  case GRID_RA:
  959. X  case GRID_DEC:
  960. X  case ECLIPT:
  961. X    break;
  962. X  case CONSTBOUND:
  963. X  case CONSTPATTRN:
  964. X    break;
  965. X  case CONSTNAME:
  966. X    font = HELVITAL;
  967. X    break;
  968. X  case CHARTFILE:
  969. X  case CURNTFONT:
  970. X  default:
  971. X    break;
  972. X  }
  973. X
  974. X  if ((font == current_font) && (fsize == current_fsize)) return;
  975. X
  976. X  switch(font)
  977. X    {
  978. X    case TIMESROMAN: fontname = timesroman_font_name; break;
  979. X    case TIMESBOLD: fontname = timesbold_font_name; break;
  980. X    case TIMESITAL: fontname = timesital_font_name; break;
  981. X    case TIMESBOLDITAL: fontname = timesboldital_font_name; break;
  982. X    case HELV: fontname = helv_font_name; break;
  983. X    case HELVBOLD: fontname = helvbold_font_name; break;
  984. X    case HELVITAL: fontname = helvital_font_name; break;
  985. X    case HELVBOLDITAL: fontname = helvboldital_font_name; break;
  986. X    case COURIER: fontname = courier_font_name; break;
  987. X    case COURITAL: fontname = courital_font_name; break;
  988. X    case COURBOLD: fontname = courbold_font_name; break;
  989. X    case COURITALBOLD: fontname = couritalbold_font_name; break;
  990. X    }
  991. X
  992. X#ifdef RELEASE3_FONTS
  993. X  sprintf(readname,"%s%d*",fontname,fsize);
  994. X#else
  995. X  sprintf(readname,"%s%d",fontname,fsize);
  996. X#endif
  997. X
  998. X  if (!(curr_xfont = XLoadQueryFont(display, readname)))
  999. X    curr_xfont = default_font;
  1000. X  else {
  1001. X    current_font = font;
  1002. X    current_fsize = fsize;
  1003. X  }
  1004. X
  1005. X  if (curr_xfont)
  1006. X    XSetFont(display, default_GC, curr_xfont->fid);
  1007. X}
  1008. X/* This routine is encouraged to look at the extern cur_funtion
  1009. X   and change the font used as desired */
  1010. X
  1011. X
  1012. Xstatic char  *intable = " 0123456789abgdezh@iklmnEoprstuOx%w";
  1013. Xstatic char *outtable = " 0123456789abgdezhqiklmnxoprstujcyw";
  1014. X/* Display text string str at x,y, in current font and font size.
  1015. X   if star_lbl is TRUE, string is a star label, use
  1016. X      greek characters (if possible) */
  1017. XD_text(x, y, s, star_lbl)
  1018. X     int x, y;
  1019. X     char *s;
  1020. X     int star_lbl;
  1021. X{
  1022. X  char ch;
  1023. X  int i, j;
  1024. X  int use_greek = FALSE;
  1025. X
  1026. X#ifdef STARXAW
  1027. X  if (is_killed()) return; /* Return if process_events returns TRUE,
  1028. X                    i.e. if the close box has been hit */
  1029. X#endif
  1030. X
  1031. X  if (star_lbl) {
  1032. X    if (isgreek(s[0]) && (isdigit(s[1]) || (s[1] == ' '))) {
  1033. X      /* Greek if first character is greek encoded,
  1034. X     and the second is space or a digit */
  1035. X      use_greek = TRUE;
  1036. X      if (greek_font)
  1037. X    XSetFont(display, default_GC, greek_font->fid);
  1038. X#ifdef OLD_GREEK
  1039. X      /* Translate yaleformat greek encoding to Symbol font encoding */
  1040. X      i = 0;
  1041. X      while (ch = s[i])
  1042. X    {
  1043. X      j = 0;
  1044. X      while (intable[j] && (intable[j] != ch)) j++;
  1045. X      s[i] = intable[j] ? outtable[j] : s[i];
  1046. X      /* If not in translation table, leave it alone */
  1047. X      i++;
  1048. X    }
  1049. X#endif
  1050. X    } else { /* Star label, but not greek */
  1051. X    /* remove leading spaces */
  1052. X    while (*s == ' ') s++;
  1053. X    }
  1054. X  }
  1055. X
  1056. X  XDrawString(display, draw_into, default_GC, x,
  1057. X          height - y, s, strlen(s));
  1058. X
  1059. X  if ((use_backup) && !hide_drawing)
  1060. X    XCopyArea(display, backup, window, default_GC, 0, 0, width, height,
  1061. X          0, 0);
  1062. X
  1063. X/*  XFlush(display);*/
  1064. X
  1065. X  if (use_greek && curr_xfont) XSetFont(display, default_GC, curr_xfont->fid);
  1066. X}
  1067. X
  1068. Xisgreek(c)
  1069. Xchar c;
  1070. X{
  1071. X  char *cp;
  1072. X
  1073. X#ifdef OLD_GREEK
  1074. X  cp = "abgdezh@iklmnEoprstuOx%w";
  1075. X#else
  1076. X  cp = "abgdezhqiklmnxoprstujcyw";
  1077. X#endif
  1078. X  while (*cp && (*cp != c)) cp++;
  1079. X  return (*cp != '\0'); /* True if letter was in greek string */
  1080. X}
  1081. X
  1082. X
  1083. X/* Return input coordinate in device coords where there are pointing devices */
  1084. XD_inxy(x, y)
  1085. X     int *x, *y;
  1086. X{
  1087. X}
  1088. X
  1089. X
  1090. X/* Put non-displayed comment in output.  Allowed in postscript, but
  1091. X   few other drivers will be able to support this. */ 
  1092. X#ifdef STARX11
  1093. XD_comment(str)
  1094. X     char *str;
  1095. X{
  1096. X  fprintf(stderr, "%s\n", str);
  1097. X}
  1098. X#endif /* STARX11 */
  1099. X
  1100. X
  1101. X
  1102. X/**
  1103. XHigher level functions
  1104. X**/
  1105. X
  1106. Xdrawlen(x, y, dx, dy, len)
  1107. X     int x,y, dx, dy, len;
  1108. X{
  1109. X  buildlines(x + dx, (int)(height - (y+dy)), x+dx+len, (int)(height - (y+dy)));
  1110. X}
  1111. X
  1112. X
  1113. XD_setcolors()
  1114. X{
  1115. X  Cardinal i;
  1116. X
  1117. X  static int data[][3] = {
  1118. X    {   0,   0,   0 },   /* BLACK */
  1119. X    { 255, 255, 255 },   /* WHITE */
  1120. X    { 255,   0,   0 },   /* RED */
  1121. X    { 255, 100,   0 },   /* ORANGE */
  1122. X    { 255, 255,   0 },   /* YELLOW */
  1123. X    {   0, 255,   0 },   /* GREEN */
  1124. X    {   0, 255, 255 },   /* CYAN */
  1125. X    {   0,   0, 255 },   /* BLUE */
  1126. X    { 255,   0, 255 },   /* VIOLET */
  1127. X    { 130, 130, 255 },   /* BLUE_WHITE */
  1128. X  };
  1129. X
  1130. X  double max_colr;
  1131. X
  1132. X  static double super_data[][3] = {
  1133. X    /*  Red             Green           Blue    Name by which type is known */
  1134. X/*  0 */    { 0.38937,        0.46526,        0.79493 },    /* B0 */
  1135. X/*  1 */    { 0.39501,        0.47146,        0.78847 },    /* B1 */
  1136. X/*  2 */    { 0.40103,        0.47792,        0.78151 },    /* B2 */
  1137. X/*  3 */    { 0.40640,        0.48355,        0.77526 },    /* B3 */
  1138. X/*  4 */    { 0.41341,        0.49071,        0.76701 },    /* B5 */
  1139. X/*  5 */    { 0.43251,        0.50914,        0.74412 },    /* B8 */
  1140. X/*  6 */    { 0.44342,        0.51897,        0.73079 },    /* B9 */
  1141. X/*  7 */    { 0.45181,        0.52618,        0.72042 },    /* A0 */
  1142. X/*  8 */    { 0.46931,        0.54026,        0.69847 },    /* A2 */
  1143. X/*  9 */    { 0.47958,        0.54792,        0.68541 },    /* A3 */
  1144. X/* 10 */    { 0.48538,        0.55205,        0.67797 },    /* A5 */
  1145. X/* 11 */    { 0.50879,        0.56731,        0.64752 },    /* F0 */
  1146. X/* 12 */    { 0.51732,        0.57231,        0.63627 },    /* F2 */
  1147. X/* 13 */    { 0.52348,        0.57573,        0.62810 },    /* F5 */
  1148. X/* 14 */    { 0.54076,        0.58447,        0.60496 },    /* F8 */
  1149. X/* 15 */    { 0.54853,        0.58799,        0.59446 },    /* G0 */
  1150. X/* 16 */    { 0.56951,        0.59623,        0.56584 },    /* G5 */
  1151. X/* 17 */    { 0.58992,        0.60244,        0.53765 },    /* K0 */
  1152. X/* 18 */    { 0.61098,        0.60693,        0.50828 },    /* K2 */
  1153. X/* 19 */    { 0.63856,        0.60977,        0.46950 },    /* K5 */
  1154. X/* 20 */    { 0.68698,        0.60595,        0.40110 },    /* M0 */
  1155. X/* 21 */    { 0.72528,        0.59434,        0.34744 },    /* M2 */
  1156. X/* 22 */    { 0.75182,        0.58144,        0.31097 },    /* M3 */
  1157. X/* 23 */    { 0.78033,        0.56272,        0.27282 },    /* M4 */
  1158. X/* 24 */    { 0.81066,        0.53676,        0.23394 },    /* M5 */
  1159. X/* 25 */    { 0.84247,        0.50195,        0.19570 },    /* M6 */
  1160. X/* 26 */    { 0.87512,        0.45667,        0.16004 },    /* M7 */
  1161. X/* 27 */    { 0.71033,        0.59983,        0.36829 },    /* N0 */
  1162. X/* 28 */    { 0.78625,        0.55816,        0.26507 },    /* N3 */
  1163. X/* 29 */    { 0.93792,        0.33011,        0.10649 },    /* N8 */
  1164. X/* 30 */    { 0.94897,        0.29906,        0.10012 },    /* N9 */
  1165. X/* 31 */    { 0.79832,        0.54811,        0.24950 },    /* S4 */
  1166. X/* 32 */    { 0.38241,        0.45743,        0.80282 },    /* O  */
  1167. X  };
  1168. X
  1169. X  XColor c;
  1170. X
  1171. X  static struct {unsigned char red, green, blue;} other_colrs[] = {
  1172. X    { 0x80, 0, 0},
  1173. X    { 0xc0, 0, 0},
  1174. X    { 0xe0, 0, 0},
  1175. X    { 0xff, 0, 0},
  1176. X    { 0x0, 0x80, 0},
  1177. X    { 0x0, 0xc0, 0},
  1178. X    { 0x0, 0xe0, 0},
  1179. X    { 0x0, 0xff, 0},
  1180. X    { 0x0, 0x0, 0x80},
  1181. X    { 0x0, 0x0, 0xc0},
  1182. X    { 0x0, 0x0, 0xe0},
  1183. X    { 0x0, 0x0, 0xff},
  1184. X    { 0x80, 0x80, 0x0},
  1185. X    { 0xc0, 0xc0, 0x0},
  1186. X    { 0xe0, 0xe0, 0x0},
  1187. X    { 0xff, 0xff, 0x0},
  1188. X    { 0x0, 0x80, 0x80},
  1189. X    { 0x0, 0xc0, 0xc0},
  1190. X    { 0x0, 0xe0, 0xe0},
  1191. X    { 0x0, 0xff, 0xff},
  1192. X    { 0x80, 0x0, 0x80},
  1193. X    { 0xc0, 0x0, 0xc0},
  1194. X    { 0xe0, 0x0, 0xe0},
  1195. X    { 0xff, 0x0, 0xff},
  1196. X    { 0x80, 0x40, 0x00},
  1197. X    { 0xc0, 0x60, 0x00},
  1198. X    { 0xe0, 0x70, 0x00},
  1199. X    { 0xff, 0x80, 0x00},
  1200. X    { 0x80, 0x80, 0x80},
  1201. X    { 0xc0, 0xc0, 0xc0},
  1202. X    { 0xe0, 0xe0, 0xe0},
  1203. X    { 0xff, 0xff, 0xff}
  1204. X  };
  1205. X
  1206. X
  1207. X  c.flags = DoRed|DoGreen|DoBlue;
  1208. X  for (i=0; i<=9; i++) {
  1209. X    c.red = 256*data[i][0];
  1210. X    c.green = 256*data[i][1];
  1211. X    c.blue = 256*data[i][2];
  1212. X    c.pixel = pixels[i];
  1213. X    XStoreColor(display, default_cmap, &c);
  1214. X  }
  1215. X  
  1216. X  if (is_super_color) {
  1217. X    star_pixels = &(pixels[i]);
  1218. X    for (i=0; i<=32; i++) {
  1219. X      max_colr = super_data[i][0];
  1220. X      max_colr = super_data[i][1] > max_colr ? super_data[i][1] : max_colr;
  1221. X      max_colr = super_data[i][2] > max_colr ? super_data[i][2] : max_colr;
  1222. X      c.red = (int) 256*255*super_data[i][0] / max_colr;
  1223. X      c.green = (int) 256*255*super_data[i][1] /max_colr;
  1224. X      c.blue = (int) 256*255*super_data[i][2] /max_colr;
  1225. X      c.pixel = star_pixels[i];
  1226. X      XStoreColor(display, default_cmap, &c);
  1227. X    }
  1228. X    for (i = 33; i <= 64; i++) {
  1229. X      c.red = other_colrs[i-33].red*256;
  1230. X      c.green = other_colrs[i-33].green*256;
  1231. X      c.blue = other_colrs[i-33].blue*256;
  1232. X      c.pixel = star_pixels[i];
  1233. X      XStoreColor(display, default_cmap, &c);
  1234. X    };
  1235. X  }
  1236. X}
  1237. X
  1238. X
  1239. X#ifndef STARXTK
  1240. X/* Differ in starXtk */
  1241. X#define MAXDRAW 250
  1242. Xstatic XSegment seg[MAXDRAW];
  1243. Xstatic int npoints = 0;
  1244. X
  1245. Xbuildlines(x1, y1, x2, y2)
  1246. X     int x1, y1, x2, y2;
  1247. X{
  1248. X#ifdef STARXAW
  1249. X  if (is_killed()) return; /* Return if process_events returns TRUE,
  1250. X                    i.e. if the close box has been hit */
  1251. X#endif
  1252. X
  1253. X  if (npoints == MAXDRAW) flushlines();
  1254. X  seg[npoints].x1 = x1;
  1255. X  seg[npoints].y1 = y1;
  1256. X  seg[npoints].x2 = x2;
  1257. X  seg[npoints].y2 = y2;
  1258. X  npoints++;
  1259. X}
  1260. X
  1261. Xflushlines()
  1262. X{
  1263. X#ifdef STARXAW
  1264. X  if (is_killed()) {
  1265. X    npoints = 0;
  1266. X    return; /* Return if process_events returns TRUE,
  1267. X           i.e. if the close box has been hit */
  1268. X  };
  1269. X#endif
  1270. X
  1271. X  curr_lsty = values_GC.line_style = LineSolid;
  1272. X  values_GC.dashes = 1;
  1273. X  XChangeGC(display, default_GC, GCLineStyle | GCDashList, &values_GC);
  1274. X
  1275. X  XDrawSegments(display, draw_into, default_GC, seg, npoints);
  1276. X  npoints = 0;
  1277. X
  1278. X  if ((use_backup) && !hide_drawing)
  1279. X    XCopyArea(display, backup, window, default_GC, 0, 0, width, height,
  1280. X          0, 0);
  1281. X  XFlush(display);
  1282. X}
  1283. X
  1284. Xkilllines()
  1285. X{
  1286. X  npoints = 0;
  1287. X}
  1288. X#endif /* not STARXtk */
  1289. X
  1290. X
  1291. X/* get global defaults from .Xdefaults */
  1292. Xget_defaults()
  1293. X{
  1294. X  char *str;
  1295. X  int i;
  1296. X
  1297. X  /* Allow fonts to be overriden */
  1298. X  if (str = XGetDefault(display, prog,"default_font_name"))
  1299. X    default_font_name = str;
  1300. X  if (str =  XGetDefault(display, prog, "greek_font_name"))
  1301. X    greek_font_name = str;
  1302. X  if (str =  XGetDefault(display, prog, "timesroman_font_name"))
  1303. X    timesroman_font_name = str;
  1304. X  if (str =  XGetDefault(display, prog, "timesbold_font_name"))
  1305. X    timesbold_font_name = str;
  1306. X  if (str =  XGetDefault(display, prog, "timesital_font_name"))
  1307. X    timesital_font_name = str;
  1308. X  if (str =  XGetDefault(display, prog, "timesboldital_font_name"))
  1309. X    timesboldital_font_name = str;
  1310. X  if (str =  XGetDefault(display, prog, "helv_font_name"))
  1311. X    helv_font_name = str;
  1312. X  if (str =  XGetDefault(display, prog, "helvbold_font_name"))
  1313. X    helvbold_font_name = str;
  1314. X  if (str =  XGetDefault(display, prog, "helvital_font_name"))
  1315. X    helvital_font_name = str;
  1316. X  if (str =  XGetDefault(display, prog, "helvboldital_font_name"))
  1317. X    helvboldital_font_name = str;
  1318. X  if (str =  XGetDefault(display, prog, "courier_font_name"))
  1319. X    courier_font_name = str;
  1320. X  if (str =  XGetDefault(display, prog, "courital_font_name"))
  1321. X    courital_font_name = str;
  1322. X  if (str =  XGetDefault(display, prog, "courbold_font_name"))
  1323. X    courbold_font_name = str;
  1324. X  if (str =  XGetDefault(display, prog, "couritalbold_font_name"))
  1325. X    couritalbold_font_name = str;
  1326. X
  1327. X  /* set post_preview, hide_drawing, use_backup from .Xdefaults */
  1328. X  if ((str = XGetDefault(display, prog, "PostscriptPreview"))
  1329. X     && (!strcmp(str, "on") || !strcmp(str, "true")))
  1330. X    post_preview = TRUE;
  1331. X  if ((str = XGetDefault(display, prog, "PostscriptLandscape"))
  1332. X     && (!strcmp(str, "on") || !strcmp(str, "true")))
  1333. X    post_landscape = TRUE;
  1334. X  if ((str = XGetDefault(display, prog, "HideDrawing"))
  1335. X     && (!strcmp(str, "on") || !strcmp(str, "true")))
  1336. X    hide_drawing = TRUE;
  1337. X  if ((str = XGetDefault(display, prog, "UseBackup"))
  1338. X     && (!strcmp(str, "on") || !strcmp(str, "true")))
  1339. X    use_backup = TRUE;
  1340. X
  1341. X  if ((str = XGetDefault(display, prog, "UseXDashes"))
  1342. X     && (!strcmp(str, "on") || !strcmp(str, "true")))
  1343. X     use_x_dashes = TRUE;
  1344. X
  1345. X  if (str = XGetDefault(display, prog, "htick_lim"))
  1346. X    htick_lim = atoi(str);
  1347. X  if (str = XGetDefault(display, prog, "htext_lim"))
  1348. X    htext_lim = atoi(str);
  1349. X  if (str = XGetDefault(display, prog, "htext_xoff"))
  1350. X    htext_xoff = atoi(str);
  1351. X  if (str = XGetDefault(display, prog, "htext_yoff"))
  1352. X    htext_yoff = atoi(str);
  1353. X  if (str = XGetDefault(display, prog, "vtick_lim"))
  1354. X    vtick_lim = atoi(str);
  1355. X  if (str = XGetDefault(display, prog, "vtext_lim"))
  1356. X    vtext_lim = atoi(str);
  1357. X  if (str = XGetDefault(display, prog, "vtext_xoff"))
  1358. X    vtext_xoff = atoi(str);
  1359. X  if (str = XGetDefault(display, prog, "vtext_yoff"))
  1360. X    vtext_yoff = atoi(str);
  1361. X
  1362. X
  1363. X/* externs for labels */
  1364. X  if (str = XGetDefault(display, prog, "x_nameoffset"))
  1365. X    x_nameoffset = atoi(str);
  1366. X  if (str = XGetDefault(display, prog, "y_nameoffset"))
  1367. X    y_nameoffset = atoi(str);
  1368. X  if (str = XGetDefault(display, prog, "x_lbloffset"))
  1369. X    x_lbloffset = atoi(str);
  1370. X  if (str = XGetDefault(display, prog, "y_lbloffset"))
  1371. X    y_lbloffset = atoi(str);
  1372. X  if (str = XGetDefault(display, prog, "x_magoffset"))
  1373. X    x_magoffset = atoi(str);
  1374. X  if (str = XGetDefault(display, prog, "y_magoffset"))
  1375. X    y_magoffset = atoi(str);
  1376. X
  1377. X/* externs for legend: variables of positioning are here */
  1378. X  if (str = XGetDefault(display, prog, "l_til"))
  1379. X    l_til = atoi(str);
  1380. X  if (str = XGetDefault(display, prog, "l_stil"))
  1381. X    l_stil = atoi(str);
  1382. X
  1383. X  if (str = XGetDefault(display, prog, "l_lmar1"))
  1384. X    l_lmar1 = atoi(str);
  1385. X  if (str = XGetDefault(display, prog, "l_lmar2"))
  1386. X    l_lmar2 = atoi(str);
  1387. X  if (str = XGetDefault(display, prog, "l_ltext"))
  1388. X    l_ltext = atoi(str);
  1389. X  if (str = XGetDefault(display, prog, "l_rmar1"))
  1390. X    l_rmar1 = atoi(str);
  1391. X  if (str = XGetDefault(display, prog, "l_rmar2"))
  1392. X    l_rmar2 = atoi(str);
  1393. X  if (str = XGetDefault(display, prog, "l_rtext"))
  1394. X    l_rtext = atoi(str);
  1395. X
  1396. X  if (str = XGetDefault(display, prog, "l_line1"))
  1397. X    l_line1 = atoi(str);
  1398. X  if (str = XGetDefault(display, prog, "l_line2"))
  1399. X    l_line2 = atoi(str);
  1400. X  if (str = XGetDefault(display, prog, "l_line3"))
  1401. X    l_line3 = atoi(str);
  1402. X  if (str = XGetDefault(display, prog, "l_line4"))
  1403. X    l_line4 = atoi(str);
  1404. X  if (str = XGetDefault(display, prog, "l_line5"))
  1405. X    l_line5 = atoi(str);
  1406. X  if (str = XGetDefault(display, prog, "l_line6"))
  1407. X    l_line6 = atoi(str);
  1408. X
  1409. X/* Point sizes for font calls */
  1410. X  if (str = XGetDefault(display, prog, "titlesize"))
  1411. X    titlesize = atoi(str);
  1412. X  if (str = XGetDefault(display, prog, "subtlsize"))
  1413. X    subtlsize = atoi(str);
  1414. X  if (str = XGetDefault(display, prog, "namesize"))
  1415. X    namesize = atoi(str);
  1416. X  if (str = XGetDefault(display, prog, "lblsize"))
  1417. X    lblsize = atoi(str);
  1418. X  if (str = XGetDefault(display, prog, "magsize"))
  1419. X    magsize = atoi(str);
  1420. X
  1421. X/* Fonts for font calls */
  1422. X  if ((str = XGetDefault(display, prog, "namefnt")) && (i = tr_fname(str)))
  1423. X    namefnt = i;
  1424. X  if ((str = XGetDefault(display, prog, "lblfnt")) && (i = tr_fname(str)))
  1425. X    lblfnt = i;
  1426. X  if ((str = XGetDefault(display, prog, "magfnt")) && (i = tr_fname(str)))
  1427. X    magfnt = i;
  1428. X  if ((str = XGetDefault(display, prog, "titlefnt")) && (i = tr_fname(str)))
  1429. X    titlefnt = i;
  1430. X  if ((str = XGetDefault(display, prog, "subtlfnt")) && (i = tr_fname(str)))
  1431. X    subtlfnt = i;
  1432. X
  1433. X/* Scale multiplier, minimum,
  1434. X   mangitude change, maximum, for thumbnail,*/
  1435. X  if (str = XGetDefault(display, prog, "th_smul"))
  1436. X    th_smul = atoi(str);
  1437. X  if (str = XGetDefault(display, prog, "th_smin"))
  1438. X    th_smin = atoi(str);
  1439. X  if (str = XGetDefault(display, prog, "th_madj"))
  1440. X    th_madj = atoi(str);
  1441. X  if (str = XGetDefault(display, prog, "th_mmax"))
  1442. X    th_mmax = atoi(str);
  1443. X}
  1444. X
  1445. X
  1446. X
  1447. Xint tr_fname(s)
  1448. Xchar *s;
  1449. X{
  1450. X  int i;
  1451. X
  1452. X  for (i = 0; s[i]; i++)
  1453. X    if (isupper(s[i]))
  1454. X      s[i] = tolower(s[i]);
  1455. X
  1456. X  if(!strcmp(s, "timesroman")) return TIMESROMAN;
  1457. X  else if (!strcmp(s, "timesbold")) return TIMESBOLD;
  1458. X  else if (!strcmp(s, "timesital")) return TIMESITAL;
  1459. X  else if (!strcmp(s, "timesboldital")) return TIMESBOLDITAL;
  1460. X  else if (!strcmp(s, "helv")) return HELV;
  1461. X  else if (!strcmp(s, "helvbold")) return HELVBOLD;
  1462. X  else if (!strcmp(s, "helvital")) return HELVITAL;
  1463. X  else if (!strcmp(s, "helvboldital")) return HELVBOLDITAL;
  1464. X  else if (!strcmp(s, "courier")) return COURIER;
  1465. X  else if (!strcmp(s, "courbold")) return COURBOLD;
  1466. X  else if (!strcmp(s, "courital")) return COURITAL;
  1467. X  else if (!strcmp(s, "couritalbold")) return COURITALBOLD;
  1468. X  else return 0;
  1469. X}
  1470. END_OF_FILE
  1471. if test 40722 -ne `wc -c <'starchart/starX11.c'`; then
  1472.     echo shar: \"'starchart/starX11.c'\" unpacked with wrong size!
  1473. fi
  1474. # end of 'starchart/starX11.c'
  1475. fi
  1476. echo shar: End of archive 29 \(of 32\).
  1477. cp /dev/null ark29isdone
  1478. MISSING=""
  1479. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 ; do
  1480.     if test ! -f ark${I}isdone ; then
  1481.     MISSING="${MISSING} ${I}"
  1482.     fi
  1483. done
  1484. if test "${MISSING}" = "" ; then
  1485.     echo You have unpacked all 32 archives.
  1486.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1487. else
  1488.     echo You still need to unpack the following archives:
  1489.     echo "        " ${MISSING}
  1490. fi
  1491. ##  End of shell archive.
  1492. exit 0
  1493.  
  1494.